# class Student:
#     def __init__(self, id, name, math, chinese, english):
#         self.id = id
#         self.name = name
#         self.math = math
#         self.chinese = chinese
#         self.english = english

# def bubble_sort(arr, basis):
#     for i in range(len(arr)):
#         for j in range(0, len(arr) - i - 1):
#             if arr[j].math < arr[j + 1].math and basis == 1:
#                 arr[j], arr[j + 1] = arr[j + 1], arr[j]
#             elif arr[j].chinese < arr[j + 1].chinese and basis == 2:
#                 arr[j], arr[j + 1] = arr[j + 1], arr[j]
#             elif arr[j].english < arr[j + 1].english and basis == 3:
#                 arr[j], arr[j + 1] = arr[j + 1], arr[j]

# def main():
#     n = int(input())
#     students = []

#     for _ in range(n):
#         id, name, math, chinese, english = input().split()
#         student = Student(id, name, float(math), float(chinese), float(english))
#         students.append(student)

#     choice = int(input())
    
#     if choice not in [1, 2, 3]:
#         print("ERROR")
#         return

#     bubble_sort(students, choice)

#     for student in students:
#         print(f"{student.id} {student.name}")

# if __name__ == "__main__":
#     main()
